home *** CD-ROM | disk | FTP | other *** search
- -- 2000.03.13
- -- Clive Green <clivegreen@atlas.co.uk>
-
- ------------------------------------------------------------------------------------------------------
-
- -- xtras setup and detection
-
- ------------------------------------------------------------------------------------------------------
-
- -- declare properties:
- property main -- main code directory object
- property loadedXtras -- a list of xtra names
- property requiredXtras -- a list of required scripting xtras
-
- property fileIOxtra -- lingo controller for fileIO functions
- property buddyAPIxtra -- lingo controller for buddyAPI functions
-
- ------------------------------------------------------------------------------------------------------
-
- on new me,L
-
- -- (1) extract and check arguments:
-
- -- check for a parameter list:
- if ilk(L) <> #propList then return [#error:#noParamListSupplied, #msg:"xtrasManager:new"]
-
- -- a reference to the parent codebase is REQUIRED:
- main = L[#main]
- if (ilk(main) <> #instance) then return [#error:#noMainObjectSupplied, #msg:"xtrasManager:new"]
-
- --------------------
-
- -- (2) compile a list of loaded xtra names:
- loadedXtras = []
-
- xL = the xtraList
- repeat with i in xL
-
- -- add the name of each xtra:
- add loadedXtras,i[#name]
-
- end repeat
-
- --------------------
-
- -- get the data manager:
- dm = main.getDataManager()
- if (ilk(dm) <> #instance) then return dm
-
- --------------------
-
- -- (3) what scripting xtras are required for programme operation?
-
- -- a list of required xtras must be provided (even if its empty):
- rxL = dm.getData([#set:#settings, #item:#requiredXtras])
- if stringP(rxL[#error]) then return rxL
-
- requiredXtras = rxL
-
- -- xtra names/requirements can vary by platform!
- um = main.getUtilityMethods()
- p = um.thePlatform()
- xL = requiredXtras[p]
-
- -- ensure that ALL of these are currently available:
- repeat with i = 1 to count(xL)
-
- -- pull ith xtra's label and name:
- x = getPropAt(xL,i)
- n = xL[i]
-
- -- fail on first xtra which turns up missing:
- if not me.xtraFound(n) then return ¬
- [#error:#requiredXtraMissing, #msg:"xtrasManager:new" && n]
-
- -- attempt to instance an object to manage this xtra:
- o = main.createInstance(x,L)
- if (ilk(o) <> #instance) then return o
-
- -- store a named reference to the xtra controller o:
- setaProp me,x,o
-
- end repeat
-
- --------------------
-
- -- pass back my address:
- return me
-
- ----------------------------------------------------------------------------------------------------
-
- on xtraFound me,n
-
- -- returns a boolean indicating whether an xtra starting with the string n is currently loaded:
-
- -- need a string to continue:
- if not stringP(n) or n = "" then return 0
-
- -- recurse until xtra is found:
- repeat with i in loadedXtras
-
- -- success:
- if i starts n then return 1
-
- end repeat
-
- -- failure:
- return 0
-
- ----------------------------------------------------------------------------------------------------
-
- on getBuddyAPIxtra me
-
- return buddyAPIxtra
-
- ----------------------------------------------------------------------------------------------------
-
- on getFileIOxtra me
-
- return fileIOxtra
-
- ----------------------------------------------------------------------------------------------------